<template>
  <div>
    <van-cell>
      <!-- 标题区域的插槽 -->
      <template #title>
        <div class="title-box">
          <!-- 标题 -->
          <span>{{ title }}</span>
          <!-- 单张图片 -->
          <img v-if="cover.type === 1"
            src="https://www.escook.cn/vuebase/pics/1.png"
            alt=""
            class="thumb"
          />
        </div>
        <!-- 三张图片 -->
        <div class="thumb-box" v-if="cover.type === 3">
          <img v-for="(item, i) in cover.images" :key="i"
            src="https://www.escook.cn/vuebase/pics/2.png"
            alt=""
            class="thumb"
          />
        </div>
      </template>
      <!-- label 区域的插槽 -->
      <template #label>
        <div class="label-box">
          <span
            >作者 {{ autName }} &nbsp;&nbsp; {{ commCount }} 评论 &nbsp;&nbsp;
            发布日期 {{ pubDate }}
          </span>
          <!-- 关闭按钮 -->
          <van-icon name="cross" />
        </div>
      </template>
      <!-- <template #default></template> -->
    </van-cell>
  </div>
</template>

<script>
export default {
  name: 'MyArticle',
  props: {
    // 标题
    title: {
      type: String,
      default: ''
    },
    // 作者
    autName: {
      type: String,
      default: ''
    },
    // 评论数
    commCount: {
      type: [String, Number],
      default: 0
    },
    // 发布时间
    pubDate: {
      type: String,
      default: ''
    },
    //
    cover: {
      type: Object,
      default: function() {
        return {
          type: 3,
          images: ['https://www.escook.cn/vuebase/pics/1.png', 'https://www.escook.cn/vuebase/pics/2.png', 'https://www.escook.cn/vuebase/pics/2.png']
        }
      }
    }
  },
  methods: {
    fn() {
      console.log(this.cover.type, this.cover.images)
    }
  }
}
</script>

<style lang="less" scoped>
.label-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.thumb {
  // 矩形黄金比例：0.618
  width: 113px;
  height: 70px;
  background-color: #f8f8f8;
  object-fit: cover;
}

.title-box {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.thumb-box {
  display: flex;
  justify-content: space-between;
}
</style>
